local zishucup__yanfeng = fk.CreateSkill{
  name = "zishucup__yanfeng",
}

Fk:loadTranslationTable{
  ["zishucup__yanfeng"] = "言锋",
  [":zishucup__yanfeng"] = "出牌阶段，你可以弃置一名其他角色一张牌，令其选择弃牌堆中一张【杀】并获得，若弃置了【杀】且与获得的【杀】不为同一张，其对你使用这两张【杀】。",

  ["#zishucup__yanfeng"] = "言锋：你可以弃置一名其他角色一张牌，有可能被其反杀。",
  ["#zishucup__yanfeng-use"] = "言锋：获得弃牌堆一张【杀】，若%dest弃置了你的【杀】（且与你获得的不为同一张），你对其使用这些【杀】。",
  ["#zishucup__yanfeng-using"] = "言锋：对%dest使用你被弃置与获得的【杀】！",

  ["$zishucup__yanfeng1"] = " ",
  ["$zishucup__yanfeng2"] = " ",
}

zishucup__yanfeng:addEffect("active", {
  card_num = 0,
  target_num = 1,
  prompt = "#zishucup__yanfeng",
  can_use = function(self, player)
    return player:usedSkillTimes(zishucup__yanfeng.name, Player.HistoryPhase) < 20 --这技能不会触发特定loop我就**，先加个网杀限制吧，刷起来都不敢想
  end,
  card_filter = Util.FalseFunc,
  target_filter = function(self, player, to_select, selected)
    return #selected == 0 and to_select ~= player and not to_select:isNude()
  end,
  on_use = function(self, room, effect)
    local player = effect.from
    local target = effect.tos[1]
    local slashready = {}
    local cards = room:askToChooseCard(player, { target = target, flag = "he", skill_name = zishucup__yanfeng.name })
    room:throwCard({cards}, self.name, target, player)
    if Fk:getCardById(cards).trueName == "slash" then
      table.insert(slashready, cards)
    end
    if player.dead or target.dead then return end
    local slashs = table.filter(room.discard_pile, function (id) return Fk:getCardById(id).trueName == "slash" end)
    if #slashs == 0 then return end
    local c = room:askToChooseCards(target, {
      target = target,
      flag = { card_data = { {"zishucup__yanfeng", slashs } } },
      min = 1,
      max = 1,
      prompt = "#zishucup__yanfeng-use::"..player.id,
      skill_name = zishucup__yanfeng.name
    })
    if #c == 1 then
      room:moveCards({
        ids = c,
        to = target,
        toArea = Card.PlayerHand,
        moveReason = fk.ReasonPrey,
        proposer = target,
        skillName = zishucup__yanfeng.name,
      })
      table.insertIfNeed(slashready, c[1])
    end
    if #slashready == 2 then
      while not player.dead and not target.dead do
        if #slashready == 0 then break end
        local slashss = table.filter(slashready, function (id)
          local card = Fk:getCardById(id)
          return target:canUseTo(card, player, {bypass_distances = true, bypass_times = true})
        end)
        if #slashss > 0 then
          local use = room:askToUseRealCard(target, {
          pattern = slashss,
          skill_name = zishucup__yanfeng.name,
          prompt = "#zishucup__yanfeng-using::"..player.id,
          extra_data = {
            bypass_times = true,
            bypass_distances = true,
            extraUse = true,
            expand_pile = slashss,
            exclusive_targets = {player.id},
          },
          skip = true,
          cancelable = false,
          })
          if use then
            table.removeOne(slashready, use.card.id)
            room:useCard(use)
          end
        else
          break
        end
      end
    end
  end,
})

return zishucup__yanfeng
